package structure

import "gddgame.cc/galaxy/utils"

type SetStruct struct {
}

func (execute *Execute) GetSetExtend(conn SafeConn, data Data, et ExtendType) []interface{} {
	key := execute.GetExtendKey(data, et)
	c, _ := conn.Do("SMEMBERS", key)
	if c == nil {
		return nil
	}
	return c.([]interface{})
}

func (execute *Execute) AddSetExtend(conn SafeConn, data Data, et ExtendType, extend []interface{}) {
	args := append([]interface{}{execute.GetExtendKey(data, et)}, extend...)
	_ = conn.Send("SADD", args...)
}

func (execute *Execute) RemoveSetExtend(conn SafeConn, data Data, et ExtendType, extend []interface{}) {
	args := append([]interface{}{execute.GetExtendKey(data, et)}, extend...)
	_ = conn.Send("SREM", args...)
}

func (execute *Execute) ExistSetExtend(conn SafeConn, data Data, et ExtendType, value interface{}) bool {
	key := execute.GetExtendKey(data, et)
	c, _ := conn.Do("SISMEMBER", key, value)
	return utils.ToInt(c) == 1
}
